package com.smartlifev30.baiwei;

import android.app.Application;

import com.smartlifev30.greendao.gen.DaoMaster;
import com.smartlifev30.greendao.gen.DaoSession;

import org.greenrobot.greendao.database.Database;


/**
 * Created by tys on 2018/8/10.
 */

public class App extends Application {
    private static App instance;
    private DaoSession daoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        initDateBase();
    }

    private void initDateBase() {
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "bw_smartlife30.db");
        Database db = helper.getWritableDb();
        daoSession = new DaoMaster(db).newSession();
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }

    public static App getInstance() {
        return instance;
    }




}
